$(function(){
	// if(window.screen.width<1600){
	// 	$("#homecss").attr("href","../css/home1180.css");
	// 	$("#headercss").attr("href","../css/header1180.css");
	// 	$("#footercss").attr("href","../css/footer1180.css");
	// }
	/*查单*/
	$(".check").mouseover(function(){
		$(this).find("dl").show();
		$(this).css("background-color","black");
	});
	$(".check").mouseout(function(){
		$(this).find("dl").hide();
		$(this).css("background-color","transparent");
	});
	
	/*网点查询*/
	$(".dotsel").mouseover(function() {
		$(".dotsel").css("background-color","black");
		$(".dotsel div").show();
		
	});
	$(".dotsel").mouseout(function(){
		$(".dotsel").css("background-color","transparent");
		$(".dotsel div").hide();
	});

	// fn_get_server("WEIGHT");
 	// fn_get_server("TIMES");
	// fn_get_server("ZZFW");
	// fn_get_notice();
	fn_get_banner();
	
	/*文章标题鼠标事件*/
	$(".article ul").on("mouseover","li", function() {
		$(this).find("a").css("color","#f18700");
		$(this).find("span").css("color","#f18700");
	});
	$(".article ul").on("mouseout","li", function() {
		$(this).find("a").css("color","#656565");
		$(this).find("span").css("color","#A9A9A9");
	});
	/*文章图片鼠标事件*/
	$("#content").on("mouseover",".article-one", function() {
		if($(this).find("img").length<1){
			$(this).stop().animate({'background-size':'105%'});
		}
	});
	$("#content").on("mouseout",".article-one", function() {
		$(this).stop().animate({'background-size':'100%'});
	});
});
function addHomeCSS() {
    
}
function fn_get_server(homeType) {
    $.ajax({
        url: '../homepage/queryHomePage',
        type: 'post',
        dataType: 'json',
        data: {
            'homeType': homeType
        },
        success: function (arr) {
            var html = "";
            var homingnull = 0;
            if (homeType == 'ZZFW') {
                html += "<tr>"
            }
            $(arr).each(function (index, cm) {
                if (cm['homeImg'] != '') {
                    if (homeType == 'ZZFW') {
                        html += '<td class="td_weight" data-parent="增值服务" data-title="' + cm['homeTitle'] + '"onclick="openTypeNew(\'' + cm['homeUrl'] + '\',\'' + cm['openType'] + '\', this)"><img src="' + cm['homeImg'] + '"/><div>' + cm['homeTitle'] + "</div></td>";
                        if (index == 3) {
                            html += "</tr><tr>"
                        }
                    } else {
                        html += '<td class="td_weight" data-parent="产品与服务" data-title="' + cm['homeTitle'] + '" onclick="openTypeNew(\'' + cm['homeUrl'] + '\',\'' + cm['openType'] + '\', this)"><img src="' + cm['homeImg'] + '"/><div>' + cm['homeTitle'] + "</div></td>";
                    }
                } else {
                    homingnull++;
                }
            });
            for (var int = 0; int < homingnull; int++) {
                if (homeType != 'ZZFW') {
                    html += "<td></td>"
                }
            }
            if (homeType == 'ZZFW') {
                html += "</tr>"
            }
            $(".div_" + homeType).html(html);
        }
    })
}

function openTypeNew(_url, _openType, clickDom) {
	var _menuName = $(clickDom).attr("data-title").replace(new RegExp("<.*?>", "g"), "");
	var _parentName = $(clickDom).attr("data-parent");

    if (_openType == "_self") {
        window.location.href = "../menu/toViewPage?url=" + encodeURIComponent(_url) + "&menuName=" + _menuName + "&parentMenuName=" + _parentName;
    } else {
        window.open("../menu/toViewPage?url=" + encodeURIComponent(_url) + "&menuName=" + _menuName + "&parentMenuName=" + _parentName);
    }
}

function href(args){
	location.href=args;
}

function fn_get_banner(){
	$.ajax({
		url:'/api/Api/queryHomePage',
		type:'post',
		data:{
			'homeType':'BANNER'
		},
        dataType: 'json',
		success:function(arr){
            var bannerHtml = '';
			$(arr).each(function(index,cm){				
				bannerHtml += '<li onclick="window.location.href=\''+cm['homeUrl']+'\'" style="background:url('+cm['homeImg']+') 50% 0 no-repeat;"></li>';
			});
            $(".slides").html(bannerHtml);
			 $(".flexslider").flexslider({
				/*slideshow:false,*/
				directionNav: true,
				pauseOnAction: false
			});
		}
	})
} 

//notice
function fn_get_notice(){
	$.ajax({
		url:'../homezone/query',
		type:'post',
        dataType: 'json',
		success:function(arr){
			var andt = '';
			var andtHtml = '';
			var schd = '';
			var schdHtml ='';
			var xpss = '';
			var xpssHtml='';
			var qysp = '';
			var qyspHtml = '';
			$(arr).each(function(i,cm){
				if(cm['zoneType']=='2'){
					if(cm['zoneFirst']=='1'){
						andtHtml="<li onclick=href('../menu/toViewPage?url="+ encodeURIComponent("../new/anenews_detail.jsp?p=5&c=5-2&id=" + cm['zoneId'])+"&noticeType=2&menuName=安能动态') class='article-one' style='background-image:url("+cm['zoneImg']+""+");'><div></div><label>"+cm['zoneTitle']+"</label></li><div class='article-onelint'></div>";
					}else{
						andt+="<li onclick=href('../menu/toViewPage?url="+encodeURIComponent("../new/anenews_detail.jsp?p=5&c=5-2&id="+cm['zoneId'])+"&noticeType=2&menuName=安能动态')><a href='#'>"+cm['zoneTitle']+"</a><span>"+cm['createDate'].substring(0,10)+"</span></li>";
					}
				}
				if(cm['zoneType']=='6'){
					if(cm['zoneFirst']=='1'){
						schdHtml = "<li onclick=href('../menu/toViewPage?url="+encodeURIComponent("../new/anenews_detail.jsp?p=3&c=3-3&id="+cm['zoneId'])+"&menuName=市场活动') class='article-one' style='background-image:url("+cm['zoneImg']+""+");'><div></div><label>"+cm['zoneTitle']+"</label></li><div class='article-onelint'></div>";
					}else{
						schd+= "<li onclick=href('../menu/toViewPage?url="+encodeURIComponent("../new/anenews_detail.jsp?p=3&c=3-3&id="+cm['zoneId'])+"&menuName=市场活动')><a href='#'>"+cm['zoneTitle']+"</a><span>"+cm['createDate'].substring(0,10)+"</span></li>";
					}
				}
				if(cm['zoneType']=='5'){
					var htmlUrl = "../menu/toViewPage?url=" + encodeURIComponent("../new/anenews_detail.jsp?p=3&c=3-2&id=" + cm['zoneId']) + "&menuName=新品上市";
					if (cm['zoneId'] == 302) {
						htmlUrl = "../menu/toViewPage?url=" + encodeURIComponent("../YouXiang/YouXiang.jsp") + "&menuName=新品上市";
					}
					if(cm['zoneFirst']=='1'){
						xpssHtml="<li  onclick=href('"+htmlUrl+"') class='article-one' style='background-image:url("+cm['zoneImg']+""+");'><div></div><label>"+cm['zoneTitle']+"</label></li><div class='article-onelint'></div>";
					}else{
						xpss+="<li onclick=href('"+htmlUrl+"')><a href='#'>"+cm['zoneTitle']+"</a><span>"+cm['createDate'].substring(0,10)+"</span></li>";
					}
				}
				if(cm['zoneType']=='v'){
					var ht="<img src='../img/video-img.png' class='videoimg'>";
					if(cm['zoneFirst']=='1'){
						qyspHtml="<li onclick=href('../menu/toViewPage?url="+encodeURIComponent("../new/video_detail.jsp?url="+cm['zoneVideo'])+"&menuName=企业视频') class='article-one' style='background-image:url("+cm['zoneImg']+""+");'>"+ht+"<div></div><label>"+cm['zoneTitle']+"</label></li><div class='article-onelint'></div>";
					}else{
						qysp+="<li onclick=href('../menu/toViewPage?url="+encodeURIComponent("../new/video_detail.jsp?url="+cm['zoneVideo'])+"&menuName=企业视频')><a href='#'>"+cm['zoneTitle']+"</a><span>"+cm['createDate'].substring(0,10)+"</span></li>";
					}
				}
			});
			$(".andt").html(andtHtml+andt);
			$(".schd").html(schdHtml+schd);
			$(".xpss").html(xpssHtml+xpss);
			$(".qysp").html(qyspHtml+qysp);
		}
	})
}

function fn_chajian(){
	var orderNo = jQuery.trim($("#txt_orderno").val());
	orderNo=orderNo.replace(/，/ig,','); 
	var yzm = jQuery.trim($("#txt_yzm").val());
	orderNo = getSplitString(orderNo);
	var reg=/^([1-9]{1}([0-9]{11}|[0-9]{7}),{0,1}){1,10}$/;
	if(!reg.test(orderNo)){
		alert("请输入合法的运单号");
		return;
	}
	if(yzm==''||yzm.length!=4){
		alert('请输入合法验证码');
		return;
	}
	$.ajax({  
		url:"../user/phoneCode",
		type:"post",
		data:{"code":yzm},
		dataType:"json",
		success:function(arr){ 
			if(arr=="0"){
				window.location.href="../search/waybillinfo.jsp?billNo="+orderNo+"&regJavaCode="+yzm;
			}else{
				alert('请输入正确的验证码');
			}
		}            
	});
}

//空白（空格、换行、tab）和逗号分隔的字符串，变成用逗号分隔  
function getSplitString(str) {  
    var arr = str.split(",");  
  
    var resources = "";  
    for (var i = 0; i < arr.length; i++) {  
        var arr1 = arr[i].split(/\s+/);  
  
        for (var j = 0; j < arr1.length; j++) {  
            if (jQuery.trim(arr1[j]) != "") {  
                resources += jQuery.trim(arr1[j]) + ",";  
            }  
        }  
    }  
  
    resources=resources.substring(0,(resources.length-1));
    return resources;  
}  

function fn_yzm_reload(){
    var verify=document.getElementById('img_yzm');
    verify.setAttribute('src','../static/createCode/makePhoneCertPic.jsp?it='+Math.random());
}


